var DataMgr = require('DataMgr');
cc.Class({
    extends: cc.Component,

    properties: {
        nodeSuccess: cc.Node, // 成功
        nodeFail: cc.Node, // 失败
        nodeLevelLabel: cc.Label, // 关卡文本
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.node.on(cc.Node.EventType.TOUCH_START, event => {
            event.stopPropagation();
        });
    },

    // update (dt) {},

    startShow(isSuccess){
        this.nodeLevelLabel.string = "LEVEL" + DataMgr.currentLevel;

        if(isSuccess){
            this.nodeSuccess.active = true;
            this.nodeFail.active = false;
    
            this.node.runAction(cc.sequence(
                cc.delayTime(1.1),
                cc.removeSelf(),
            ));
        }
        else{
            this.nodeSuccess.active = false;
            this.nodeFail.active = true;
        }        
    },

    onClick(event, data){
        switch(data){
            case 'quickstart':{
                cc.director.loadScene('game');
                break;
            }
            case 'againstart':{
                cc.director.loadScene('start');
                break;
            }
        }
    },
});
